<%@ page language="java" contentType="text/html; charset=ISO-8859-1" import="java.util.*,common.Funcs,entity.*" 
    pageEncoding="ISO-8859-1"%>
<%
	// check whether user login, if not, redirect to Login page
	User curUser = (User) session.getAttribute("curUserInfo");
	if (curUser == null)
	{
		response.sendRedirect("Login.jsp");
		return;
	}
	
	int menuId = 0;
	String starPage = "";
	if (request.getParameter("menuId") != null) {
		menuId = Integer.parseInt(request.getParameter("menuId"));
	}
	// get left menu list
	ArrayList<Menu> menus = Funcs.getLeftMenu(menuId);
	// get initial page
	if (menuId == 0)
	{
		starPage = "Admin/UserList.jsp";
	}
	else if (menuId == 1)
	{
		starPage = "InsuranceList.jsp";
	}
	else if (menuId == 2)
	{
		starPage = "TicketsList.jsp";
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Exhibition Management System</title>
<link href="css/mwn.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/mwn.js"></script>
<script type="text/javascript">
function nTabs1(tabObj,objId){
	var tabList = document.getElementById(tabObj).getElementsByTagName("a");
	for(i=0; i <tabList.length; i++)
	{
		if (tabList[i].id == objId)
		{
			document.getElementById(tabObj+"_Title"+i).className = 'menu_btn_'+i+' '+'oncl'; 
		}else{
			document.getElementById(tabObj+"_Title"+i).className = 'menu_btn_'+i; 
		}
	}
}

function openUrl(url){
	document.getElementById( "main_frame" ).src=url;
}

</script>
</head>
<body>

<div id="PageHeader">
    <div class="top_panel">
        <div class="logo"></div>
        <em class="spliter"></em>
        <div class="top_navi" id="naTab1">
            <a id="naTab1_Title0" class="menu_btn_0 oncl" href="Default.jsp?menuId=0"><span>Admin</span></a>
            <a id="naTab1_Title1" class="menu_btn_1" href="Default.jsp?menuId=1"><span>Security</span></a>
            <a id="naTab1_Title2" class="menu_btn_2" href="Default.jsp?menuId=2"><span>Marketing</span></a>
        </div>
        <div class="top_info">
            <%=curUser.getUserName()%> | <a href="Login.jsp" title="Log out">Log out</a>
        </div>
        <em class="spliter fRight"></em>
    </div>
</div>
<div id="PageMain">
    <div id="PageSider">
    	<div class="sider">
            <div class="sider_wrap" id="sider_wrap">
                <div class="function_list">
                	<div class="list list_act">
                		<%
						for (int i = 0; i < menus.size(); i++) {
								Menu menu = (Menu) menus.get(i);
						%>
						<a href="javascript:;" onclick="openUrl('<%=menu.getMenuUrl() %>')"><%=menu.getMenuTile()%></a>
						<%}
						%>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="PagePanel">
    	<div class="main">
            <div class="panel_wrap" id="panel_wrap">
				<iframe class='panel panel_s' id='main_frame' frameborder='0' src='<%=starPage%>'></iframe>
            </div>
        </div>
    </div>
</div>
<div id="PageFooter">UMASS Dartmouth CIS 532 &copy;2012</div>
<input type="hidden" id="hid1" value="<%=menuId%>">
</body>
</html>
<script type="text/javascript">
// change selected top menu style
var topMenuId = document.getElementById("hid1").value;
nTabs1('naTab1','naTab1_Title'+topMenuId);
</script>